package com.bridge.bridge_wd.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;

import com.bridge.bridge_wd.R;
import com.bridge.bridge_wd.databinding.ActivityYijianfankuiBinding;
import com.bridge.common.base.BaseActivity;
import com.bridge.common.http.RetrofitHelper;
import com.bridge.common.utils.ToastshowUtils;
import com.bridge.common.utils.UltimateBarXUtils;

import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * @ClassName YiJianFanKuiActivity
 * @Description TODO消息
 * @Author xushufeng
 * @CreateDate 2021/4/11 0011 12:42
 * @Version 1.0
 * @UpdateDate 2021/4/11 0011 12:42
 * @UpdateRemark 更新说明
 */
public class YiJianFanKuiActivity extends BaseActivity {
    ActivityYijianfankuiBinding binding;

    @Override
    protected int layoutId() {
        return R.layout.activity_yijianfankui;
    }

    @Override
    protected void initView() {

        binding = getBind();
        binding.btnRegisn.setOnClickListener(this);
        UltimateBarXUtils.setAppBar(this, true, true, R.color.white);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view.getId() == R.id.btn_regisn) {

            if (TextUtils.isEmpty(binding.edYijianfankui.getText().toString())) {
                Toast.makeText(YiJianFanKuiActivity.this, "输入内容不能为空", Toast.LENGTH_LONG).show();
                return;
            }
            HashMap map = new HashMap();
            map.put("token", 1);
            map.put("contact", binding.edYijianfankui.getText().toString());
            map.put("content", 10);
            Observable<ResponseBody> call = RetrofitHelper.getApiService().feedback(getRqBody(map, null));
            doHttp(101, call, getString(R.string.loading), null);
        }
    }
    @Override
    public void onSuccess(int requestCode, String result) {
        super.onSuccess(requestCode, result);
        switch (requestCode){
            case 101 :
                //这两行是你要转换  成的bean 对象   ， 返回的外层统一格式  在 BaseBean里 ，根据情况定制
                // code  已经在外部处理过了  ，这是 code == 1 情况下的  回调
//                XsCallBean anjianListBean = BaseBean.fromJson(result,XsCallBean.class);
//                List<XsCallBean.DataBean> dataList = anjianListBean.getData();
                break;
        }
    }

    @Override
    public void onFailure(int requestCode, String msg) {
        super.onFailure(requestCode, msg);
        //无网络情况 ，请求失败
    }
    @Override
    protected void setListenner() {

    }
}
